<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" type="text/css" href="${base}/statics/easyui/material/easyui.css">
	<link rel="stylesheet" type="text/css" href="${base}/statics/easyui/icon.css">
	<script type="text/javascript" src="${base}/statics/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="${base}/statics/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${base}/statics/easyui/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="${base}/statics/easyui/common.js"></script>
	<script type="text/javascript" src="${base}/statics/lib/layer/2.1/layer.js"></script> 
	<script type="text/javascript" src="${base}/statics/h-ui/js/H-ui.js"></script> 
	<script type="text/javascript" src="${base}/statics/h-ui.admin/js/H-ui.admin.js"></script> 
</head>
<body class="easyui-layout">
<div data-options="region:'center'" style="padding:8px 0 0 20px">
	<table style="width:100%;height:0px" id="tb_datagrid"></table>
</div>

<script type="text/javascript">
	
	$(function(){
		
		datagrid();
		
	});
	var toolbar = [{
		text:'添加',
		iconCls:'icon-add',
		handler:function(){
			//Hui_admin_custom_tab("${ctrname}/add","添加规格");
			layer_show("添加规格","${ctrname}/add","","500",function(){});
		}
	},{
		text:'修改',
		iconCls:'icon-edit',
		handler:function(){
			var nodes=$('#tb_datagrid').treegrid("getSelections");
			if(nodes!=null&&nodes.length>1){
				layer.msg("只能选中一条记录");
				return;
			}
			var data=$('#tb_datagrid').treegrid("getSelected");
			if(data==null){
				layer.msg("请选中一条记录");
				return;
			}
			layer_show("编辑规格","${ctrname}/edit?id="+data.brand_id,"","500",function(){});
			
		}
	},'-',{
		text:'删除',
		iconCls:'icon-remove',
		handler:function(){
			var nodes=$('#tb_datagrid').treegrid("getSelections");
			if(nodes!=null&&nodes.length>1){
				layer.msg("只能选中一条记录");
				return;
			}
			var data=$('#tb_datagrid').treegrid("getSelected");
			if(data==null){
				layer.msg("请选中一条记录");
				return;
			}
			layer.confirm('是否删除【'+data.rule_name+'】?', {
			  btn: ['确定','取消'] //按钮
			}, function(){
				$.getJSON("${ctrname}/remove?id="+data.rule_id,function(data){
					layer.msg(data.msg);
					if(data.status==1){
						datagrid();
					}
				});
			}, function(){
			  
			});
			
		}
	}];
	
	function datagrid(){
		$('#tb_datagrid').datagrid({
			url:'${ctrname}/datagrid',
			rownumbers:true,
			singleSelect:false,
			pageSize:20,           
			pagination:true,
			multiSort:true,
			fitColumns:true,
			fit:true,
			toolbar:toolbar,
			columns:[[
				{ field:'rule_name',title:'规格名称',width:20},
				{ field:'rule_memo',title:'规格备注',width:60},
				{ field:'rule_id',title:'操作',width:60,formatter: function(value, row, index){
					return '<a onclick="ruledata('+value+')" style="color:blue;">【参数列表】</a>';
				}},
				
			]],
			onLoadSuccess:function(){
				$("#tb_datagrid").css("height",$(window).height()-20);
			}
		});
	}
	function addruledata(id){
		layer_show("添加规格参数","${ctrname}/addruledata?id="+id,"","500",function(){});
	}
	function ruledata(id){
		//layer_show("规格参数","${ctrname}/ruledata?id="+id,"800","500",function(){});
		var index=layer.open({
			type: 2,
			area: ["800px", "500px"],
			fix: false, //不固定
			maxmin: true,
			shade:0.4,
			title: "规格值列表",
			content: "${ctrname}/ruledata?id="+id
		});
		layer.full(index);
	}
</script>
</body>
</html>